# -*- coding: utf-8 -*-
import scrapy
from siwi.items import MeizituItem

class MeizituSpider(scrapy.Spider):
    name = 'meizitu'
    allowed_domains = ['www.meizitu.com']
    start_urls = ['http://www.meizitu.com/a/sexy.html']

    def parse(self, response):
        for sel in response.xpath('//ul[@class="wp-list clearfix"]/li'):
            title = sel.xpath('div/div/a/img/@alt').extract_first()
            link = sel.xpath('div/div/a/@href').extract_first()
            yield scrapy.Request(link, self.getdetail)

    def getdetail(self, response):
        # item = MeizituItem()
        for sel in response.xpath('//div[@id="picture"]/p/img'):
            # item['title'] = '1'
            img = sel.xpath('@src').extract_first()
            # item['image_urls'].append(img)
            print(img)
            # yield item
